package com.mvc.demo;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("test")
public class TestController {

    public TestController() {
        System.out.println("TestController->instance");
    }

    @RequestMapping("/index")
    public String index() {
        System.out.println("+++++");
        return "redirect:/index.jsp";
    }

    @RequestMapping("/add")
    public ModelAndView add() {
        System.out.println("=====");
        return new ModelAndView("redirect:/index.jsp");
    }


    @RequestMapping("/json.action")
    public @ResponseBody Map<String,Object> json() {
        Map<String, Object> map = new HashMap<>();
        map.put("name","gerry");
        map.put("sex","男");
        map.put("birth", "1990-02-31");

        return map;
    }

}
